/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.math.BigDecimal;
import java.io.Serializable;

/**
* @website https://el-admin.vip
* @description /
* @author ...
* @date 2020-11-08
**/
@Entity
@Data
@Table(name="shuyi_order")
public class Order implements Serializable {

    private static final long serialVersionUID = 4904559977840945312L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "order_id")
    @ApiModelProperty(value = "订单编号,自增长 ")
    private Integer orderId;

    @Column(name = "reader_id",nullable = false)
    @NotNull
    @ApiModelProperty(value = "读者编号 ")
    private Integer readerId;

    @Column(name = "out_trade_no",unique = true,nullable = false)
    @NotBlank
    @ApiModelProperty(value = "商户系统内部订单号，要求32个字符内，只能是数字、大小写字母_-|*@ ，且在同一个商户号下唯一。 ")
    private String outTradeNo;

    @Column(name = "total_price",nullable = false)
    @NotNull
    @ApiModelProperty(value = "总价格 ")
    private BigDecimal totalPrice;

    @Column(name = "order_time")
    @ApiModelProperty(value = "下单时间 ")
    private Timestamp orderTime;

    @Column(name = "handling_time")
    @ApiModelProperty(value = "处理时间 ")
    private Timestamp handlingTime;

    @Column(name = "borrow_list_id",nullable = false)
    @NotNull
    @ApiModelProperty(value = "借书编号 ")
    private Integer borrowListId;

    @Column(name = "content")
    @ApiModelProperty(value = "备注 ")
    private String content;

    @Column(name = "status")
    @ApiModelProperty(value = "0:预支付 1：支付成功 2：取消支付或支付失败")
    private Integer status;

    @Column(name = "is_enable",nullable = false)
    @NotNull
    @ApiModelProperty(value = "是否启用 1启用 0未启用")
    private Boolean isEnable;

    public void copy(Order source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}